/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EC;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author TrangNHIT
 */
@Entity
@Table(name = "tbOrders")
@NamedQueries({
    @NamedQuery(name = "Orders.findAll", query = "SELECT o FROM Orders o"),
    @NamedQuery(name = "Orders.findByOrderID", query = "SELECT o FROM Orders o WHERE o.orderID = :orderID"),
    @NamedQuery(name = "Orders.findByOrderDateOfPuchase", query = "SELECT o FROM Orders o WHERE o.orderDateOfPuchase = :orderDateOfPuchase"),
    @NamedQuery(name = "Orders.findByOrderTotal", query = "SELECT o FROM Orders o WHERE o.orderTotal = :orderTotal"),
    @NamedQuery(name = "Orders.findByOrderStatus", query = "SELECT o FROM Orders o WHERE o.orderStatus = :orderStatus")})
public class Orders implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Order_ID")
    private Integer orderID;
    @Basic(optional = false)
    @Column(name = "Order_DateOfPuchase")
    @Temporal(TemporalType.TIMESTAMP)
    private Date orderDateOfPuchase;
    @Basic(optional = false)
    @Column(name = "Order_Total")
    private double orderTotal;
    @Basic(optional = false)
    @Column(name = "Order_Status")
    private String orderStatus;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "orders")
    private List<OrderDetails> orderDetailsList;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "orders")
    private Bills bills;
    @JoinColumn(name = "Cust_ID", referencedColumnName = "Cust_ID")
    @ManyToOne(optional = false)
    private Customers customers;

    public Orders() {
    }

    public Orders(Integer orderID) {
        this.orderID = orderID;
    }

    public Orders(Integer orderID, Date orderDateOfPuchase, double orderTotal, String orderStatus) {
        this.orderID = orderID;
        this.orderDateOfPuchase = orderDateOfPuchase;
        this.orderTotal = orderTotal;
        this.orderStatus = orderStatus;
    }

    public Integer getOrderID() {
        return orderID;
    }

    public void setOrderID(Integer orderID) {
        this.orderID = orderID;
    }

    public Date getOrderDateOfPuchase() {
        return orderDateOfPuchase;
    }

    public void setOrderDateOfPuchase(Date orderDateOfPuchase) {
        this.orderDateOfPuchase = orderDateOfPuchase;
    }

    public double getOrderTotal() {
        return orderTotal;
    }

    public void setOrderTotal(double orderTotal) {
        this.orderTotal = orderTotal;
    }

    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public List<OrderDetails> getOrderDetailsList() {
        return orderDetailsList;
    }

    public void setOrderDetailsList(List<OrderDetails> orderDetailsList) {
        this.orderDetailsList = orderDetailsList;
    }

    public Bills getBills() {
        return bills;
    }

    public void setBills(Bills bills) {
        this.bills = bills;
    }

    public Customers getCustomers() {
        return customers;
    }

    public void setCustomers(Customers customers) {
        this.customers = customers;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (orderID != null ? orderID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orders)) {
            return false;
        }
        Orders other = (Orders) object;
        if ((this.orderID == null && other.orderID != null) || (this.orderID != null && !this.orderID.equals(other.orderID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "EC.Orders[orderID=" + orderID + "]";
    }

}
